package com.sqzstudy.properties.controller;

import com.sqzstudy.properties.entity.ConfigBean;
import com.sqzstudy.properties.entity.QiRobotVo;
import com.sqzstudy.properties.entity.User;
import com.sqzstudy.properties.service.WeiTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fangzhipeng on 2017/4/18.
 */
@RestController
@EnableConfigurationProperties({ConfigBean.class, User.class})
public class LucyController {
    @Autowired
    ConfigBean configBean;

    @RequestMapping(value = "/lucy")
    public String lucy(){
        return configBean.getGreeting()+" >>>>"+configBean.getName()+" >>>>"+ configBean.getUuid()+" >>>>"+configBean.getMax();
    }

    @Autowired
    User user;
    @Autowired
    WeiTemplateService weiTemplateService;
    @RequestMapping(value = "/user")
    public String user(){
        return user.getName()+user.getAge();
    }


    @GetMapping(value = "testApi4")
    public void testBosRoBot() throws Exception {
        QiRobotVo vo = new QiRobotVo();
        //机器人地址
        vo.setWebhookAddress("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cb47bc50-b118-427c-81e3-2d4901c0f9c7");
        //1.第一种情况：发送文本消息
        vo.setContent("我是程大勇");
        List<String> memberList = new ArrayList<>();
        memberList.add("程勇");
        memberList.add("@all");
//        vo.setMemberList(memberList);
//        vo.setMsgType("text");

        //2.第二种情况，发送图片消息
        vo.setMsgType("image");
        vo.setSavePath("D:/image/8.jpg");

        //3.第三种情况，发送机器人消息
//        vo.setMsgType("news");
//        vo.setTitle("中秋节礼品领取");
//        vo.setDescription("今年中秋节公司有豪礼相送");
//        vo.setUrl("URL");
//        vo.setImageUrl("http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png");
        weiTemplateService.testSendNews(vo);

    }

}
